package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.ICompanyDao;
import com.cn.wanxi.dao.impl.CompanyDaoImpl;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.service.ICompanyService;
import redis.clients.jedis.Jedis;

public class CompanyServiceImpl implements ICompanyService {
    ICompanyDao companyDao = new CompanyDaoImpl();

    @Override
    public CompanyModel getCompany() {
        Jedis jedis = new Jedis();
        if (jedis.get("company_id") != null)
            return companyDao.getCompanyByRedis();
        else{
            CompanyModel company = companyDao.getCompany();
            companyDao.setCompanyInRedis(company);
            return company;
        }
    }

    @Override
    public int editCompany(CompanyModel company) {
        return companyDao.editCompany(company);
    }
}
